﻿/**************************************************************
*作者：Leon
*创建时间：2022/4/5 17:16:11
**************************************************************/
using System.Globalization;
using System.Windows.Data;

namespace Lad.DrawProject.Controls.Converters;

public sealed class TrueToFalseConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return !(bool)value;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

public sealed class NullableToBooleanConverter : IValueConverter
{
    public bool NullValue { get; set; } = false;
    public bool NotNullValue { get; set; } = true;

    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return value == null ? NullValue : NotNullValue;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return Binding.DoNothing;
    }
}
